<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ taglib uri="/WEB-INF/tlds/att.tld" prefix="att"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   <meta name="decorator" content="sysDefault"/>
	<script type="text/javascript" src="${staticPath}/lib/jQuery-File-Upload/9.5.2/js/jquery-1.8.2.min.js"></script>
	<link rel="stylesheet" href="${staticPath}/lib/jQuery-File-Upload/9.5.2/css/jquery.fileupload-ui.css" type="text/css"></link> 
	<link rel="stylesheet" href="${staticPath}/lib/bootstrap/2.3.2/css/bootstrap.min.css" type="text/css"></link>
    <script src="${staticPath}/lib/jQuery-File-Upload/9.5.2/js/vendor/jquery.ui.widget.js"></script>
    <script src="${staticPath}/lib/jQuery-File-Upload/9.5.2/js/tmpl.min.js"></script>
    <script src="${staticPath}/lib/jQuery-File-Upload/9.5.2/js/load-image.min.js"></script>
    <script src="${staticPath}/lib/jQuery-File-Upload/9.5.2/js/canvas-to-blob.min.js"></script>
    <script src="${staticPath}/lib/bootstrap/2.3.2/js/bootstrap.min.js"></script>
    <script src="${staticPath}/lib/bootstrap/2.3.2/js/bootstrap-image-gallery.min.js"></script>
    <script src="${staticPath}/lib/jQuery-File-Upload/9.5.2/js/jquery.iframe-transport.js"></script>
    <script src="${staticPath}/lib/jQuery-File-Upload/9.5.2/js/jquery.fileupload.js"></script>
    <script src="${staticPath}/lib/jQuery-File-Upload/9.5.2/js/jquery.fileupload-fp.js"></script>
    <script src="${staticPath}/lib/jQuery-File-Upload/9.5.2/js/jquery.fileupload-ui.js"></script>
<script type="text/javascript">
var srcObject=null;
var tempData=null;
var maxNumber=${upload.maxNumber};
var maxSize=${upload.maxSize};


function selectAtt(){
	$("input:checkbox").each(function(){
		if(tempData==null){
			tempData=$(this).val();
		}else{
			tempData=tempData+','+$(this).val();
		}
	});
	if(tempData==null){
		alert('你还没有上传附件！！');
		return ;
	}
	srcObject='['+tempData+']';
	var obj={srcValue:srcObject};
	window.returnValue=obj;
	window.close(); 
} 

$(function () {
	'use strict'
	$('#fileupload').fileupload({
		maxFileSize: maxSize,     // 5 MB
		maxNumberOfFiles:maxNumber, //最大条数
		acceptFileTypes:/(\.|\/)(${upload.accept})$/i
	});
});
</script>


  </head>
  <body>
<div class="col-xs-10">
	<div class="container">
	<form id="fileupload" action="${contextPath}${upload.url}"  method="post" enctype="multipart/form-data">
	<div class="row fileupload-buttonbar">
	<div class="span7">
	<span class="btn btn-success fileinput-button">

	<span>选择文件</span>
	<input type="file"  name="files[]" multiple>
	</span>
	</div>
	<div class="span5 fileupload-progress fade">
	<div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
	<div class="bar" style="width:0%;"></div>
	</div>
	<div class="progress-extended">&nbsp;</div>
	</div>
	</div>
	<div class="fileupload-loading"></div>
	<table role="presentation" class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody></table>
	</form>
	</DIV>
	<div class="col-sm-offset-2 col-sm-10">
	<input class="btn btn-primary" type="button" onclick="selectAtt()" value="确定"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<input class="btn btn-default" type="button" value="取消" onclick="window.close()"/>
	</div>
	</div>
	
<script id="template-upload" type="text/x-tmpl">
			{% for (var i=0, file; file=o.files[i]; i++) { %}
			<tr class="template-upload fade">
			<td  class="preview"><span class="fade"></span></td>
			<td  class="name"><span id="filename">{%=file.name%}</span></td>
			<td  class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
			{% if (file.error) { %}
			<td class="error" colspan="2"><span class="label label-important">Error</span> {%=file.error%}</td>
			{% } else if (o.files.valid && !i) { %}
			<td>
			<div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="bar" style="width:0%;"></div></div>
			</td>
			<td class="start">{% if (!o.options.autoUpload) { %}
            <button class="btn btn-primary">
            <i class="icon-upload icon-white"></i>
            <span>上传文件</span>
            </button>
            {% } %}</td>
            {% } else { %}
             <td colspan="2"></td>
            {% } %}
            <td class="cancel">{% if (!i) { %}
            <button class="btn btn-warning">
            <i class="icon-ban-circle icon-white"></i>
            <span>取消上传</span>
            </button>
            {% } %}</td>
            </tr>
            {% } %}
           
  </script>

 <script id="template-download" type="text/x-tmpl">
        	<table  id="productTable">
            {% for (var i=0, file; file=o.files[i]; i++) { %}
            <tr class="template-download fade">
            {% if (file.error) { %}
             <td id ='error'></td>
          
            <td id='name' class="name"><span id="filename">{%=file.name%}</span></td>
             <td id='size' class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
            <td class="error" colspan="2"><span class="label label-important">Error</span> {%=file.error%}</td>
            {% } else { %}
            <td id='preview' class="preview">{% if (file.thumbnail_url) { %}
            <a href="{%=file.url%}" title="{%=file.name%}" rel="gallery" download="{%=file.name%}"><img src="{%=file.thumbnail_url%}"></a>
            {% } %}</td>
            <td class="name">
            <a href="{%=file.url%}" title="{%=file.attid%}" rel="{%=file.thumbnail_url&&'gallery'%}" download="{%=file.name%}">{%=file.name%}</a>
            </td>
            <td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
            <td colspan="2"></td>
            {% } %}
            <td class="delete">
            <button class="btn btn-danger" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}"{% if (file.delete_with_credentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
            <i class="icon-trash icon-white"></i>
            <span>删除文件</span>
            </button>
            </td>
             <td  id='attid'><input type="checkbox" name="attBox" value="{attid:'{%=file.attid%}',url:'{%=file.thumbnail_url%}',name:'{%=file.name%}'}"></td>
            </tr>
            {% } %}
 </table>
 </script>
</body>
</html>


   
